Ext.ux.ModifyOnline = Ext.extend(Ext.Window, {
	initComponent : function(config) {
		var basePath = document.getElementById('basePath').href;
		var linedata = Ext.getCmp("onlineDataGrid").getStore()
				.getAt(Ext.getCmp("onlineDataGrid").getSelectionModel().lastActive);
		
		var modifyForm = new Ext.FormPanel({
        	labelWidth : 100, // label settings here cascade unless overridden
			url : basePath + 'online/update.action',
			autoScroll:true,
			frame : true,
			region : 'center',
			border:true,
			fileUpload: true,
			bodyStyle : 'padding:5px 5px 0',
			width : '100%',
			defaults : {
				width : 220
			},
			defaultType : 'textfield',

			items : [{
				fieldLabel : '邮箱',
				name : 'online.qqNum',
				id:'onlineQqUpdate',
				allowBlank : false
			}],
			bbar : ['->', {
				text : '保存',
				handler:function() {
					if(!modifyForm.form.isValid()) {
						return;
					}
					modifyForm.form.submit( {
						url : basePath + 'online/update.action?online.id=' + linedata.json.id,
						method : "POST",
						success : function(form, action) {
							form.reset();
							Ext.getCmp('modifyOnlineWin').close();
							Ext.MessageBox.alert('提示', '更新成功');
							Ext.StoreMgr.get('onlineStore').reload();
						},
						failure : function(form, action) {
							if (action.failureType == Ext.form.Action.SERVER_INVALID)
								Ext.MessageBox.alert('警告', action.result.msg);
						}
					});
				}
			}]
		});
		
		Ext.Ajax.request( {
			url : basePath + 'online/load.action?online.id=' + linedata.json.id,
			method : 'post',
			callback : function(op, success, response) {
				var jsonObject = eval('(' + response.responseText + ')');
				Ext.getCmp("onlineQqUpdate").setValue(jsonObject.qqNum);
			}
		});
		
		Ext.apply(this, {
			title: "修改在线客服信息",
	        plain: true,
	        width:400,
	        height:150,
	        modal: true,
	        maximizable:true,
	        border: false,
	        layout: 'border',
	        autoScroll:true,
	        items: [modifyForm]
		});
		Ext.ux.ModifyOnline.superclass.initComponent.apply(this, arguments);
	}
});
Ext.reg('lgnModifyOnline', Ext.ux.ModifyOnline);
